package org.bmi.gwt.examples.echo.shared;

import java.util.Date;

import org.bmi.gwt.mi.shared.MiObject;

import com.google.gwt.dom.client.Document;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.RootPanel;

public class EchoObject implements MiObject
{
	/*
	 * The provided argument has no purpose, just to show how a proxy should be
	 * annotated to chose a constructor, and to show how to call this
	 * constructor from a proxy.
	 */

	public EchoObject(String str)
	{}

	public void echo(Date date, String str)
	{
		RootPanel rootPanel = RootPanel.get();
		Element body = rootPanel.getElement();

		String text = str + " in " + (new Date().getTime() - date.getTime()) + " millisecunds";

		body.appendChild(Document.get().createBRElement());
		body.appendChild(Document.get().createTextNode(text));
	}
}
